<?php
if (!defined('BASEPATH'))
	exit('No direct script access allowed');

class Web_settings extends MX_Controller {

	public function __construct() {
		parent::__construct();

		$this->load->model('admin_settings_model');
		$this->load->model(array('admin_commoncall','admin_settings_model'));
		$this->load->model('settings_model');
			
		$this->template->set_theme('admin');
		$this->template->set_layout('default');
		$this->template->set_partial('side_menu','layouts/side_menu');
		$this->template->set_partial('nav_bar','layouts/nav_bar');
		$this->template->set_partial('footer','footer/footer');


	}
	public function index()
	{
	
		$configuration = $this->admin_settings_model->get_configuration(1);
		
          if ($configuration) {

			$data['web_title'] = $configuration->web_title;
          	$data['web_url'] = $configuration->web_url;
          	$data['web_friendly_name'] = $configuration->web_friendly_name;
          	$data['keyword'] = $configuration->keyword;
          	$data['description'] = $configuration->description;
          	$data['default_email'] = $configuration->default_email;
          	$data['google_analytics'] = $configuration->google_analytics;
          	$data['currency'] = $configuration->currency;
          	$data['tagline'] = $configuration->tagline;
          	$data['call_now'] = $configuration->call_now;
          	$data['facebook_link'] = $configuration->facebook_link;
          	$data['linkedin_link'] = $configuration->linkedin_link;
          	$data['twitter_link'] = $configuration->twitter_link;
          	
        }
		$this->template->build('settings/web_configuration',$data);
	}
	
	function web_settings_update() {
		
		$web_title = $_POST['web_title'];
		$web_url = $_POST['web_url'];
		$web_friendly_name = $_POST['web_friendly_name'];
		$keyword = $_POST['keyword'];
		$description = $_POST['description'];
		$default_email = $_POST['default_email'];
		$google_analytics = $_POST['google_analytics'];
		//$currency = $_POST['currency'];
		//$tagline = $_POST['tagline'];
		//$call_now = $_POST['call_now'];
		//$facebook_link = $_POST['facebook_link'];
		//$linkedin_link = $_POST['linkedin_link'];
		//$twitter_link = $_POST['twitter_link'];
		
		$configuration_data = array(
				'web_title' => $web_title,
				'web_url' => $web_url,
				'web_friendly_name' => $web_friendly_name,
				'keyword' => $keyword,
				'description' => $description,
				'default_email' => $default_email,
				'google_analytics' => $google_analytics,
				//'currency' => $currency,
				//'tagline' => $tagline,
				//'call_now' => $call_now,
				//'facebook_link' => $facebook_link,
				//'linkedin_link' => $linkedin_link,
				//'twitter_link' => $twitter_link,
		
		);
	
		//var_dump($configuration_data);
		//die();
		//if ($this->config->item('mode') != 'DEMO')
		$this->db->update('web_configuration', $configuration_data);
		$this->session->set_flashdata('message', 'Web Settings Updated Sucessfully..........');
		redirect('secure/settings/web_settings');
	}
}